<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>

$(function(){
	//弹出框设置
	$("#dialogDiv").dialog({
		title:"公文信息",//标题
		width: 800,//宽度
	    height: 350,//高度
	    closed: true,//初始关闭
	    cache: false,//缓存
	    modal: true,
	    buttons:[
			{
				text:'关闭',
				handler:function(){$('#dialogDiv').dialog("close");}
			}
		],
	    onClose: function() {
			 $("#dialogIframe").attr("src","");
			} 
	});	
	
	//查询按钮绑定点击事件
	$("#searchButton").click(function(){
		$('#synFromTable').datagrid({ queryParams:getParams()});
	});	
		
	//表格加载
	$('#synFromTable').datagrid({
	    url:'<c:url value="/docDispatch/listCompleteReceipt"/>',
	    queryParams:getParams(),//提交参数
	    toolbar:'#synFromToolbar',//表头工具栏
	    pagination:true,//显示分页  
	    pagePosition:'bottom',//分页栏出现位置
	    pageNumber:1,//初始页码
	    pageSize:10,//初始每页显示记录数量
	    singleSelect:true,
	    columns:[[
			{field:'index',title:'序号',formatter: function(value,row,index){
				return (index+1);
			},width:40},
			{field:'docName',title:'公文标题',width:270},
			{field:'displayNumber',title:'文号',width:160},
			{field:'dispatchOrg',title:'发文单位',width:150},
			{field:'sendTime',title:'发文时间',width:160,formatter: function(value,row,index){
				var fromDate="";
				if(value){
					fromDate=dataFormatStr(new Date(value),"yyyy-MM-dd hh:mm:ss");
				}
				return fromDate;
			}},
			{field: "docId" ,hidden:"true"},
			{field: "dispatchOrgCode" ,hidden:"true"},
			{field:'docInfo',title:'公文信息',width:120,formatter: function(value,row,index){
				return "<a href='javascript:void(0)' onclick='openDocInfo(this)'>查看</a>";
			}}
	    ]]
	});
});

//关闭弹出框
function closeDialog(){
	$('#synFromTable').datagrid({ queryParams:getParams()});
	$('#dialogDiv').dialog('close');
}

//查看公文信息
function openDocInfo(obj){
	//var docId = $(obj).closest('tr').find(':radio').val();
	var docId = $(obj).closest('tr').find('td').eq(5).text();
	$("#dialogIframe").attr("src","<c:url value='/receive/viewDocIssueInfo'/>?timeType=sendTime&docId="+docId);
	$('#dialogDiv').dialog('open').window('center');
	
	/*var vHeight=320;                          //弹出窗口的宽度; 
    var vWidth=800;                         //弹出窗口的高度; 
    //获得窗口的垂直位置 
    var iTop = (window.screen.availHeight - 30 - vHeight) / 2; 
    //获得窗口的水平位置 
    var iLeft = (window.screen.availWidth - 10 - vWidth) / 2; 
	var url="<c:url value='/receive/viewDocIssueInfo'/>?docId="+docId;
	var winFeatures = "height="+vHeight+"px,width="+vWidth+"px,top=" + iTop + ",left=" + iLeft + ",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no";
	window.open(url,'_blank',winFeatures);	*/	
}

//查询条件生成方法
function getParams(){
	var jsonObj=new Object();
	if($('input[name="docName"]').val()!=""){
		jsonObj.docName=$('input[name="docName"]').val();
	}
	if($('input[name="displayNumber"]').val()!=""){
		jsonObj.displayNumber=$('input[name="displayNumber"]').val();
	}
	if($('input[name="dispatchOrg"]').val()!=""){
		jsonObj.dispatchOrg=$('input[name="dispatchOrg"]').val();
	}
	if($('input[name="createTime"]').val()!=""){
		jsonObj.createTime=$('input[name="createTime"]').val();
	}
	return jsonObj;
}